{% extends 'base.html' %}

{% block title %}首页 - 区块链交易行为特征分析与可视化系统{% endblock %}

{% block content_no_sidebar %}
<div class="row justify-content-center">
    <div class="col-md-10">
        <div class="card">
            <div class="card-body text-center">
                <h1 class="display-4 mb-4"><i class="fas fa-cubes text-primary me-3"></i>区块链交易行为特征分析与可视化系统</h1>
                <p class="lead">一个强大的区块链交易数据分析平台，帮助您深入了解交易行为特征并识别潜在的非法账号</p>
                <hr class="my-4">
                {% if not session.get('user_id') %}
                <div class="d-grid gap-2 d-md-flex justify-content-md-center">
                    <a href="{{ url_for('login') }}" class="btn btn-primary btn-lg me-md-2">
                        <i class="fas fa-sign-in-alt me-2"></i>登录系统
                    </a>
                    <a href="{{ url_for('register') }}" class="btn btn-outline-primary btn-lg">
                        <i class="fas fa-user-plus me-2"></i>注册账号
                    </a>
                </div>
                {% else %}
                <div class="d-grid gap-2 d-md-flex justify-content-md-center">
                    <a href="{{ url_for('dashboard') }}" class="btn btn-primary btn-lg">
                        <i class="fas fa-tachometer-alt me-2"></i>进入仪表盘
                    </a>
                </div>
                {% endif %}
            </div>
        </div>

        <div class="row mt-5">
            <div class="col-md-4 mb-4">
                <div class="card h-100">
                    <div class="card-body text-center">
                        <i class="fas fa-database text-primary fa-3x mb-3"></i>
                        <h3 class="card-title">交易数据管理</h3>
                        <p class="card-text">导入历史交易数据，查看交易明细，汇总分析并导出数据报告。</p>
                    </div>
                </div>
            </div>
            <div class="col-md-4 mb-4">
                <div class="card h-100">
                    <div class="card-body text-center">
                        <i class="fas fa-chart-line text-primary fa-3x mb-3"></i>
                        <h3 class="card-title">数据可视化</h3>
                        <p class="card-text">直观展示交易数据趋势、用户交易次数占比和交易金额分布。</p>
                    </div>
                </div>
            </div>
            <div class="col-md-4 mb-4">
                <div class="card h-100">
                    <div class="card-body text-center">
                        <i class="fas fa-shield-alt text-primary fa-3x mb-3"></i>
                        <h3 class="card-title">非法账号识别</h3>
                        <p class="card-text">基于先进的机器学习模型，识别潜在的非法交易账号。</p>
                    </div>
                </div>
            </div>
        </div>

        {% if total_transactions is defined and total_transactions > 0 %}
        <div class="card mt-4">
            <div class="card-header bg-primary text-white">
                <h5 class="mb-0"><i class="fas fa-chart-bar me-2"></i>系统数据概览</h5>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <div class="card border-left-primary h-100 py-2">
                            <div class="card-body">
                                <div class="row no-gutters align-items-center">
                                    <div class="col mr-2">
                                        <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">总交易数</div>
                                        <div class="h5 mb-0 font-weight-bold text-gray-800">{{ total_transactions|default(0) }}</div>
                                    </div>
                                    <div class="col-auto">
                                        <i class="fas fa-exchange-alt fa-2x text-gray-300"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 mb-3">
                        <div class="card border-left-success h-100 py-2">
                            <div class="card-body">
                                <div class="row no-gutters align-items-center">
                                    <div class="col mr-2">
                                        <div class="text-xs font-weight-bold text-success text-uppercase mb-1">总地址数</div>
                                        <div class="h5 mb-0 font-weight-bold text-gray-800">{{ total_addresses|default(0) }}</div>
                                    </div>
                                    <div class="col-auto">
                                        <i class="fas fa-address-book fa-2x text-gray-300"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                {% if recent_transactions %}
                <h5 class="mt-4 mb-3">最近交易</h5>
                <div class="table-responsive">
                    <table class="table table-hover table-sm">
                        <thead>
                            <tr>
                                <th>交易哈希</th>
                                <th>时间</th>
                                <th>发送方</th>
                                <th>接收方</th>
                                <th>金额</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for tx in recent_transactions %}
                            <tr>
                                <td title="{{ tx.tx_hash }}">{{ tx.tx_hash[:8] }}...</td>
                                <td>{{ tx.timestamp|timestamp_to_date }}</td>
                                <td title="{{ tx.from_address }}">{{ tx.from_address[:8] }}...</td>
                                <td title="{{ tx.to_address }}">{{ tx.to_address[:8] }}...</td>
                                <td>{{ tx.value }}</td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                <div class="text-center mt-3">
                    <a href="{{ url_for('transactions') }}" class="btn btn-primary btn-sm">
                        <i class="fas fa-list me-2"></i>查看更多交易
                    </a>
                </div>
                {% endif %}
            </div>
        </div>
        {% endif %}
        
        <div class="card mt-4">
            <div class="card-body">
                <h3 class="card-title">系统特点</h3>
                <ul class="list-group list-group-flush">
                    <li class="list-group-item">
                        <i class="fas fa-check-circle text-success me-2"></i>
                        <strong>全面的数据分析：</strong>支持多维度分析区块链交易数据
                    </li>
                    <li class="list-group-item">
                        <i class="fas fa-check-circle text-success me-2"></i>
                        <strong>直观的可视化展示：</strong>通过图表直观展示数据特征和趋势
                    </li>
                    <li class="list-group-item">
                        <i class="fas fa-check-circle text-success me-2"></i>
                        <strong>智能的异常检测：</strong>利用机器学习模型识别可疑交易行为
                    </li>
                    <li class="list-group-item">
                        <i class="fas fa-check-circle text-success me-2"></i>
                        <strong>便捷的数据管理：</strong>支持数据导入、查询、汇总和导出
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
{% endblock %}